#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

int cmp(const void* a, const void* b){
	return *(int*)b - *(int*)a;
}
int main(){
	int number = 0, i = 0,j = 0, z = 0, size = 0;
	int data[100] = {0}, num[100] = {0}, output[100] = {0};
	int N = 0;
	//输入6个 不大于100的正整数
	scanf("%d", &N);	

	for(i = 0; i < N; i++){
		scanf("%d", &num[i]);
	}
	//得到所有步数
	for(i = 0; i < N; i++){
		number = num[i];
		do{
			if(number == 1){
				break;
			}
			number = (number % 2 == 0)?(number / 2):((3 * number + 1) / 2);
			data[size++] = number;
		}while(1);
	}
	//得到未覆盖数
	for(i = 0; i < N; i++){
		for(j = 0; j < size - 1; j++){
			if(num[i] == data[j]){
				break;
			}
		}
		if(j == size - 1){
			output[z++] = num[i];
		}
	}
	//未覆盖数从大到小输出
	qsort(output, z, sizeof(int), cmp);
	for(i = 0; i < z - 1; i++){
		printf("%d ", output[i]);
	}
	printf("%d\n", output[i]);
	return 0;
}
